<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>login page</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#login_btn").on('click', function(){
                // userName = $("#userName").val();
                // password = $("#password").val();
                $.post(
                    "/login",
                    // {"userName":userName,"password":password},
                    $("#form1").serialize(),
                    function(data){
                        if(data == "fail"){
                            $("#msg").text("登录失败,请重试!");
                        }else if(data != ""){
                            document.location.href=data;
                        }
                    },
                    "text"
                );
            });
        });
    </script>
</head>
<body>
    <h4 id="msg"></h4>
    <form id="form1" action="/login" method="post">
        用户名：<input type="text" id="userName" name="userName" value="">
        <br>
        密码：<input type="password" id="password" name="password" value="">
        <input id="login_btn" type="button" value="登录">
    </form>
</body>
</html>
